package com.sam.jifenbao;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TabHost;

import com.sam.adapter.CouponListAdapter;
import com.sam.entity.CouponEntity;
import java.util.ArrayList;
import java.util.List;

public class CouponListActivity extends BaseActivity {
    private TabHost tabHost;
    private ListView validCouponListView,invalidCouponListView;
    final List<CouponEntity> couponList = new ArrayList<>();

    private static final String VALID_COUPON_TAB_TAG = "valid";
    private static final String INVALID_COUPON_TAB_TAG = "invalid";
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coupon_list);
        findView();
        initView();
    }

    @Override
    protected void findView() {
        tabHost = (TabHost) findViewById(android.R.id.tabhost);
        validCouponListView = (ListView) findViewById(R.id.valid_coupon_listview);
        invalidCouponListView = (ListView) findViewById(R.id.invalid_coupon_listview);
    }

    @Override
    protected void initView() {
        tabHost.setup();
        final String validStr = getString(R.string.valid);
        final String invalidStr = getString(R.string.invalid);
        tabHost.addTab(tabHost.newTabSpec(VALID_COUPON_TAB_TAG).setContent(R.id.valid_coupon_listview).setIndicator(validStr));
        tabHost.addTab(tabHost.newTabSpec(INVALID_COUPON_TAB_TAG).setContent(R.id.invalid_coupon_listview).setIndicator(invalidStr));

        for(int i = 0; i <20; i++) couponList.add(new CouponEntity(5+i,"新店沙拉套餐优惠券-"+i,
                10+i,System.currentTimeMillis(), System.currentTimeMillis()));
        validCouponListView.setAdapter(new CouponListAdapter(this,couponList));
        validCouponListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                Intent intent = new Intent(CouponListActivity.this,CouponDetailActivity.class);
//                Map<String,String> clickedMap = couponList.get(position);
//                intent.putExtra("sss",);
//                startActivity(intent);
            }
        });
    }
}
